<?php
declare (strict_types = 1);
namespace app\adminapi\controller\system\auth;
use think\exception\HttpException;
use think\Request;
use adminmatrix\server\app\adminMatrix;
use think\response\Json;
use app\adminapi\logic\system\auth\AdminUserLogic;
use adminmatrix\server\app\server\JsonService;
use adminmatrix\annotation\auth\IsPermission;
class AdminUserController extends AdminMatrix
{


    public function lists(Request $request)
    {
        return $this->dataLists();
    }

     public function save(Request $request , AdminUserLogic $logic) : Json
     {
         try {
             $logic -> save($request);
             return  JsonService::success("新增成功");
         } catch (HttpException $e)
         {
             return JsonService::fail($e->getMessage());
         }
     }



     public function update( Request $request , AdminUserLogic $logic) : Json
     {
         try {
             $logic->update($request);
             return JsonService::success('更新成功');
         } catch (HttpException $e)
         {
             return JsonService::fail($e->getMessage());
         }
     }

     public function delete(int $id , Request $request , AdminUserLogic $logic) : Json
     {
         try {
             $logic->delete($id);
             return JsonService::success('删除成功');
         } catch (HttpException $e)
         {
             return JsonService::fail($e->getMessage());
         }
     }

     public function getAuthRole(Request $request ,AdminUserLogic $logic) : Json
     {
         try {
             $role = $logic->getRole();
             return JsonService::success($role);
         } catch (HttpException $exception)
         {
             return JsonService::fail($exception->getMessage());
         }
     }
     public function mySelf(AdminUserLogic $logic) : Json
     {
         try {
             $logis = $logic->detail();
             return JsonService::success($logis);
         } catch (HttpException $e)
         {
             return JsonService::fail($exception->getMessage());

         }
     }

}